/*     */ package com.wgcloud.controller;
/*     */

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageInfo;
import com.wgcloud.config.CommonConfig;
import com.wgcloud.dto.ChartInfo;
import com.wgcloud.entity.*;
import com.wgcloud.service.*;
import com.wgcloud.util.FormatUtil;
import com.wgcloud.util.HostUtil;
import com.wgcloud.util.PageUtil;
import com.wgcloud.util.ThreadPoolUtil;
import com.wgcloud.util.license.LicenseUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/dash"})
/*     */ public class DashboardCotroller {
/*     */   private void testThread() {
/*  45 */     Runnable runnable = () -> logger.info("DashboardCotroller----------testThread");
/*     */ 
/*     */     
/*  48 */     ThreadPoolUtil.executor.execute(runnable);
/*     */   }
/*     */ 
/*     */   
/*  52 */   private static final Logger logger = LoggerFactory.getLogger(com.wgcloud.controller.DashboardCotroller.class);
/*     */   
/*     */   @Resource
/*     */   DbTableService dbTableService;
/*     */   
/*     */   @Resource
/*     */   PortInfoService portInfoService;
/*     */   
/*     */   @Resource
/*     */   DceInfoService dceInfoService;
/*     */   
/*     */   @Resource
/*     */   DbInfoService dbInfoService;
/*     */   
/*     */   @Resource
/*     */   SystemInfoService systemInfoService;
/*     */   
/*     */   @Resource
/*     */   AppInfoService appInfoService;
/*     */   
/*     */   @Resource
/*     */   FileWarnInfoService fileWarnInfoService;
/*     */   @Resource
/*     */   FileWarnStateService fileWarnStateService;
/*     */   @Resource
/*     */   DockerInfoService dockerInfoService;
/*     */   @Resource
/*     */   LogInfoService logInfoService;
/*     */   @Autowired
/*     */   HeathMonitorService heathMonitorService;
/*     */   @Autowired
/*     */   HostGroupService hostInfoService;
/*     */   @Autowired
/*     */   CpuStateService cpuStateService;
/*     */   @Autowired
/*     */   MemStateService memStateService;
/*     */   @Autowired
/*     */   SysLoadStateService sysLoadStateService;
/*     */   @Autowired
/*     */   NetIoStateService netIoStateService;
/*     */   @Autowired
/*     */   DeskStateService deskStateService;
/*     */   @Autowired
/*     */   DeskIoService deskIoService;
/*     */   @Autowired
/*     */   DiskSmartService diskSmartService;
/*     */   @Resource
/*     */   CpuTemperaturesService cpuTemperaturesService;
/*     */   @Autowired
/*     */   CommonConfig commonConfig;
/*     */   
/*     */   @RequestMapping({"main"})
/*     */   public String mainList(Model model, HttpServletRequest request) {
/* 105 */     Map<String, Object> params = new HashMap<>();
/*     */     
/*     */     try {
/* 108 */       int totalSystemInfoSize = this.systemInfoService.countByParams(params);
/* 109 */       model.addAttribute("totalSystemInfoSize", Integer.valueOf(totalSystemInfoSize));
/* 110 */       params.put("state", "2");
/* 111 */       int hostDownSize = this.systemInfoService.countByParams(params);
/* 112 */       model.addAttribute("hostDownSize", Integer.valueOf(hostDownSize));
/*     */       
/* 114 */       params.clear();
/* 115 */       int totalSizeApp = this.appInfoService.countByParams(params);
/* 116 */       model.addAttribute("totalSizeApp", Integer.valueOf(totalSizeApp));
/* 117 */       int dockerSize = this.dockerInfoService.countByParams(params);
/* 118 */       model.addAttribute("dockerSize", Integer.valueOf(dockerSize));
/*     */       
/* 120 */       params.put("state", "2");
/* 121 */       int downAppSize = this.appInfoService.countByParams(params);
/* 122 */       model.addAttribute("downAppSize", Integer.valueOf(downAppSize));
/* 123 */       int downDockerSize = this.dockerInfoService.countByParams(params);
/* 124 */       model.addAttribute("downDockerSize", Integer.valueOf(downDockerSize));
/*     */       
/* 126 */       setPieChart(model, totalSystemInfoSize);
/*     */       
/* 128 */       setMiddleData(model);
/*     */       
/* 130 */       params.clear();
/* 131 */       int portSize = this.portInfoService.countByParams(params);
/* 132 */       model.addAttribute("portSize", Integer.valueOf(portSize));
/* 133 */       params.put("state", "2");
/* 134 */       int portDownSize = this.portInfoService.countByParams(params);
/* 135 */       model.addAttribute("portDownSize", Integer.valueOf(portDownSize));
/*     */       
/* 137 */       params.clear();
/* 138 */       int dceSize = this.dceInfoService.countByParams(params);
/* 139 */       model.addAttribute("dceSize", Integer.valueOf(dceSize));
/* 140 */       params.put("resTimes", Integer.valueOf(-1));
/* 141 */       int dceDownSize = this.dceInfoService.countByParams(params);
/* 142 */       model.addAttribute("dceDownSize", Integer.valueOf(dceDownSize));
/*     */       
/* 144 */       params.clear();
/* 145 */       Integer fileWarnSize = this.fileWarnInfoService.countByParams(params);
/* 146 */       model.addAttribute("fileWarnSize", Integer.valueOf((fileWarnSize == null) ? 0 : fileWarnSize.intValue()));
/*     */       
/* 148 */       params.clear();
/* 149 */       PageInfo pageInfoDbTableList = this.dbTableService.selectByParams(params, 1, 30);
/* 150 */       model.addAttribute("dbTableList", JSONUtil.parseArray(pageInfoDbTableList.getList()));
/*     */       
/* 152 */       params.clear();
/* 153 */       int dbInfoSize = this.dbInfoService.countByParams(params);
/* 154 */       model.addAttribute("dbInfoSize", Integer.valueOf(dbInfoSize));
/*     */       
/* 156 */       params.clear();
/* 157 */       params.put("dbState", "2");
/* 158 */       int dbInfoDownSize = this.dbInfoService.countByParams(params);
/* 159 */       model.addAttribute("dbInfoDownSize", Integer.valueOf(dbInfoDownSize));
/*     */       
/* 161 */       params.clear();
/* 162 */       int heathSize = this.heathMonitorService.countByParams(params);
/* 163 */       model.addAttribute("heathSize", Integer.valueOf(heathSize));
/* 164 */       params.put("heathStatus", "200");
/* 165 */       int heath200Size = this.heathMonitorService.countByParams(params);
/* 166 */       model.addAttribute("heath200Size", Integer.valueOf(heath200Size));
/* 167 */       model.addAttribute("heatherrSize", Integer.valueOf(heathSize - heath200Size));
/*     */     
/*     */     }
/* 170 */     catch (Exception e) {
/* 171 */       logger.error("主面板信息异常", e);
/* 172 */       this.logInfoService.save("主面板信息异常", e.toString(), "1");
/*     */     } 
/* 174 */     if (request.getParameter("dashView") != null) {
/* 175 */       return "dashView/index";
/*     */     }
/* 177 */     return "index";
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void setMiddleData(Model model) throws Exception {
/* 189 */     Map<String, Object> params = new HashMap<>();
/* 190 */     List<SystemInfo> list = this.systemInfoService.selectAllByParams(params);
/* 191 */     Double maxCpu = Double.valueOf(0.0D);
/* 192 */     Double avgCpu = Double.valueOf(0.0D);
/* 193 */     Double minCpu = Double.valueOf(1000.0D);
/* 194 */     Double sumCpu = Double.valueOf(0.0D);
/*     */     
/* 196 */     Double maxMem = Double.valueOf(0.0D);
/* 197 */     Double minMem = Double.valueOf(1000.0D);
/* 198 */     Double avgMem = Double.valueOf(0.0D);
/* 199 */     Double sumMem = Double.valueOf(0.0D);
/*     */     
/* 201 */     Double maxRxbyt = Double.valueOf(0.0D);
/* 202 */     Double avgRxbyt = Double.valueOf(0.0D);
/* 203 */     Double minRxbyt = Double.valueOf(1000.0D);
/* 204 */     Double sumRxbyt = Double.valueOf(0.0D);
/*     */     
/* 206 */     Double maxTxbyt = Double.valueOf(0.0D);
/* 207 */     Double minTxbyt = Double.valueOf(1000.0D);
/* 208 */     Double avgTxbyt = Double.valueOf(0.0D);
/* 209 */     Double sumTxbyt = Double.valueOf(0.0D);
/*     */     
/* 211 */     Double maxFiveLoad = Double.valueOf(0.0D);
/* 212 */     Double avgFiveLoad = Double.valueOf(0.0D);
/* 213 */     Double minFiveLoad = Double.valueOf(1000.0D);
/* 214 */     Double sumFiveLoad = Double.valueOf(0.0D);
/*     */     
/* 216 */     Double maxFifteenLoad = Double.valueOf(0.0D);
/* 217 */     Double minFifteenLoad = Double.valueOf(1000.0D);
/* 218 */     Double avgFifteenLoad = Double.valueOf(0.0D);
/* 219 */     Double sumFifteenLoad = Double.valueOf(0.0D);
/*     */     
/* 221 */     int systemSize = 0;
/*     */     
/* 223 */     int cpuCoresSum = 0;
/* 224 */     double memSum = 0.0D;
/*     */     
/* 226 */     for (SystemInfo systemInfo : list) {
/*     */ 
/*     */ 
/*     */       
/* 230 */       systemSize++;
/*     */       
/* 232 */       if (null != systemInfo.getCpuPer()) {
/* 233 */         if (systemInfo.getCpuPer().doubleValue() > maxCpu.doubleValue()) {
/* 234 */           maxCpu = systemInfo.getCpuPer();
/*     */         }
/* 236 */         if (systemInfo.getCpuPer().doubleValue() < minCpu.doubleValue()) {
/* 237 */           minCpu = systemInfo.getCpuPer();
/*     */         }
/* 239 */         sumCpu = Double.valueOf(sumCpu.doubleValue() + systemInfo.getCpuPer().doubleValue());
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 244 */       if (null != systemInfo.getMemPer()) {
/* 245 */         if (systemInfo.getMemPer().doubleValue() > maxMem.doubleValue()) {
/* 246 */           maxMem = systemInfo.getMemPer();
/*     */         }
/* 248 */         if (systemInfo.getMemPer().doubleValue() < minMem.doubleValue()) {
/* 249 */           minMem = systemInfo.getMemPer();
/*     */         }
/* 251 */         sumMem = Double.valueOf(sumMem.doubleValue() + systemInfo.getMemPer().doubleValue());
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 256 */       if (null != systemInfo.getRxbyt()) {
/* 257 */         if (Double.valueOf(systemInfo.getRxbyt()).doubleValue() > maxRxbyt.doubleValue()) {
/* 258 */           maxRxbyt = Double.valueOf(systemInfo.getRxbyt());
/*     */         }
/* 260 */         if (Double.valueOf(systemInfo.getRxbyt()).doubleValue() < minRxbyt.doubleValue()) {
/* 261 */           minRxbyt = Double.valueOf(systemInfo.getRxbyt());
/*     */         }
/* 263 */         sumRxbyt = Double.valueOf(sumRxbyt.doubleValue() + Double.valueOf(systemInfo.getRxbyt()).doubleValue());
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 268 */       if (null != systemInfo.getTxbyt()) {
/* 269 */         if (Double.valueOf(systemInfo.getTxbyt()).doubleValue() > maxTxbyt.doubleValue()) {
/* 270 */           maxTxbyt = Double.valueOf(systemInfo.getTxbyt());
/*     */         }
/* 272 */         if (Double.valueOf(systemInfo.getTxbyt()).doubleValue() < minTxbyt.doubleValue()) {
/* 273 */           minTxbyt = Double.valueOf(systemInfo.getTxbyt());
/*     */         }
/* 275 */         sumTxbyt = Double.valueOf(sumTxbyt.doubleValue() + Double.valueOf(systemInfo.getTxbyt()).doubleValue());
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 280 */       if (null != systemInfo.getFiveLoad()) {
/* 281 */         if (Double.valueOf(systemInfo.getFiveLoad().doubleValue()).doubleValue() > maxFiveLoad.doubleValue()) {
/* 282 */           maxFiveLoad = Double.valueOf(systemInfo.getFiveLoad().doubleValue());
/*     */         }
/* 284 */         if (Double.valueOf(systemInfo.getFiveLoad().doubleValue()).doubleValue() < minFiveLoad.doubleValue()) {
/* 285 */           minFiveLoad = Double.valueOf(systemInfo.getFiveLoad().doubleValue());
/*     */         }
/* 287 */         sumFiveLoad = Double.valueOf(sumFiveLoad.doubleValue() + Double.valueOf(systemInfo.getFiveLoad().doubleValue()).doubleValue());
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 292 */       if (null != systemInfo.getFifteenLoad()) {
/* 293 */         if (Double.valueOf(systemInfo.getFifteenLoad().doubleValue()).doubleValue() > maxFifteenLoad.doubleValue()) {
/* 294 */           maxFifteenLoad = Double.valueOf(systemInfo.getFifteenLoad().doubleValue());
/*     */         }
/* 296 */         if (Double.valueOf(systemInfo.getFifteenLoad().doubleValue()).doubleValue() < minFifteenLoad.doubleValue()) {
/* 297 */           minFifteenLoad = Double.valueOf(systemInfo.getFifteenLoad().doubleValue());
/*     */         }
/* 299 */         sumFifteenLoad = Double.valueOf(sumFifteenLoad.doubleValue() + Double.valueOf(systemInfo.getFifteenLoad().doubleValue()).doubleValue());
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/*     */       try {
/* 305 */         cpuCoresSum += Integer.valueOf(systemInfo.getCpuCoreNum()).intValue();
/* 306 */       } catch (Exception e) {
/* 307 */         logger.error("统计所有主机总核数错误", e);
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/*     */       try {
/* 313 */         memSum += Double.valueOf(systemInfo.getTotalMem().replace("G", "")).doubleValue();
/* 314 */       } catch (Exception e) {
/* 315 */         logger.error("统计所有主机总内存错误", e);
/*     */       } 
/*     */     } 
/*     */ 
/*     */ 
/*     */     
/* 321 */     if (systemSize > 0) {
/* 322 */       avgCpu = Double.valueOf(sumCpu.doubleValue() / list.size());
/* 323 */       avgMem = Double.valueOf(sumMem.doubleValue() / list.size());
/* 324 */       avgRxbyt = Double.valueOf(sumRxbyt.doubleValue() / list.size());
/* 325 */       avgTxbyt = Double.valueOf(sumTxbyt.doubleValue() / list.size());
/* 326 */       avgFifteenLoad = Double.valueOf(sumFifteenLoad.doubleValue() / list.size());
/* 327 */       avgFiveLoad = Double.valueOf(sumFiveLoad.doubleValue() / list.size());
/*     */     } else {
/* 329 */       minCpu = Double.valueOf(0.0D);
/* 330 */       minMem = Double.valueOf(0.0D);
/* 331 */       minRxbyt = Double.valueOf(0.0D);
/* 332 */       minTxbyt = Double.valueOf(0.0D);
/* 333 */       avgFifteenLoad = Double.valueOf(0.0D);
/* 334 */       avgFiveLoad = Double.valueOf(0.0D);
/*     */     } 
/*     */     
/* 337 */     model.addAttribute("cpuCoresSum", Integer.valueOf(cpuCoresSum));
/* 338 */     model.addAttribute("memSum", Double.valueOf(FormatUtil.formatDouble(Double.valueOf(memSum), 2)));
/*     */ 
/*     */     
/* 341 */     List<ChartInfo> cpuInfoList = new ArrayList();
/* 342 */     ChartInfo maxCpuInfo = new ChartInfo();
/* 343 */     maxCpuInfo.setValue(maxCpu);
/* 344 */     maxCpuInfo.setItem("CPU%最高");
/* 345 */     cpuInfoList.add(maxCpuInfo);
/* 346 */     ChartInfo avgCpuInfo = new ChartInfo();
/* 347 */     avgCpuInfo.setValue(Double.valueOf(FormatUtil.formatDouble(avgCpu, 2)));
/* 348 */     avgCpuInfo.setItem("CPU%平均");
/* 349 */     cpuInfoList.add(avgCpuInfo);
/* 350 */     ChartInfo minCpuInfo = new ChartInfo();
/* 351 */     minCpuInfo.setValue(minCpu);
/* 352 */     minCpuInfo.setItem("CPU%最低");
/* 353 */     cpuInfoList.add(minCpuInfo);
/* 354 */     model.addAttribute("cpuInfoList", cpuInfoList);
/*     */ 
/*     */ 
/*     */     
/* 358 */     List<ChartInfo> memInfoList = new ArrayList();
/* 359 */     ChartInfo maxMemInfo = new ChartInfo();
/* 360 */     maxMemInfo.setValue(maxMem);
/* 361 */     maxMemInfo.setItem("内存%最高");
/* 362 */     memInfoList.add(maxMemInfo);
/* 363 */     ChartInfo avgMemInfo = new ChartInfo();
/* 364 */     avgMemInfo.setValue(Double.valueOf(FormatUtil.formatDouble(avgMem, 2)));
/* 365 */     avgMemInfo.setItem("内存%平均");
/* 366 */     memInfoList.add(avgMemInfo);
/* 367 */     ChartInfo minMemInfo = new ChartInfo();
/* 368 */     minMemInfo.setValue(minMem);
/* 369 */     minMemInfo.setItem("内存%最低");
/* 370 */     memInfoList.add(minMemInfo);
/* 371 */     model.addAttribute("memInfoList", memInfoList);
/*     */ 
/*     */     
/* 374 */     model.addAttribute("maxRxbyt", FormatUtil.kbToM(maxRxbyt + "") + "/s");
/* 375 */     model.addAttribute("minRxbyt", FormatUtil.kbToM(minRxbyt + "") + "/s");
/* 376 */     model.addAttribute("avgRxbyt", FormatUtil.kbToM(FormatUtil.formatDouble(avgRxbyt, 2) + "") + "/s");
/* 377 */     model.addAttribute("maxTxbyt", FormatUtil.kbToM(maxTxbyt + "") + "/s");
/* 378 */     model.addAttribute("minTxbyt", FormatUtil.kbToM(minTxbyt + "") + "/s");
/* 379 */     model.addAttribute("avgTxbyt", FormatUtil.kbToM(FormatUtil.formatDouble(avgTxbyt, 2) + "") + "/s");
/*     */     
/* 381 */     model.addAttribute("maxFiveLoad", maxFiveLoad);
/* 382 */     model.addAttribute("minFiveLoad", minFiveLoad);
/* 383 */     model.addAttribute("avgFiveLoad", Double.valueOf(FormatUtil.formatDouble(avgFiveLoad, 2)));
/* 384 */     model.addAttribute("maxFifteenLoad", maxFifteenLoad);
/* 385 */     model.addAttribute("minFifteenLoad", minFifteenLoad);
/* 386 */     model.addAttribute("avgFifteenLoad", Double.valueOf(FormatUtil.formatDouble(avgFifteenLoad, 2)));
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void setPieChart(Model model, int totalSystemInfoSize) throws Exception {
/* 397 */     Map<String, Object> params = new HashMap<>();
/* 398 */     List<ChartInfo> chartInfoList1 = new ArrayList<>();
/* 399 */     List<ChartInfo> chartInfoList2 = new ArrayList<>();
/*     */ 
/*     */     
/* 402 */     params.put("memPer", Integer.valueOf(95));
/* 403 */     int memPerSize_95 = this.systemInfoService.countByParams(params);
/* 404 */     double a = 0.0D;
/* 405 */     if (totalSystemInfoSize != 0) {
/* 406 */       a = memPerSize_95 / totalSystemInfoSize;
/*     */     }
/* 408 */     ChartInfo memPerSize_95_chart = new ChartInfo();
/* 409 */     memPerSize_95_chart.setItem("内存>=95%");
/* 410 */     memPerSize_95_chart.setCount(Integer.valueOf(memPerSize_95));
/* 411 */     memPerSize_95_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(a), 2)));
/* 412 */     chartInfoList1.add(memPerSize_95_chart);
/* 413 */     params.clear();
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 418 */     params.put("memPer", Integer.valueOf(90));
/* 419 */     params.put("memPerLe", Integer.valueOf(95));
/* 420 */     int memPerSize_90_95 = this.systemInfoService.countByParams(params);
/* 421 */     double a_90_95 = 0.0D;
/* 422 */     if (totalSystemInfoSize != 0) {
/* 423 */       a_90_95 = memPerSize_90_95 / totalSystemInfoSize;
/*     */     }
/* 425 */     ChartInfo memPerSize_90_95_chart = new ChartInfo();
/* 426 */     memPerSize_90_95_chart.setItem("内存>=90%且<95%");
/* 427 */     memPerSize_90_95_chart.setCount(Integer.valueOf(memPerSize_90_95));
/* 428 */     memPerSize_90_95_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(a_90_95), 2)));
/* 429 */     chartInfoList1.add(memPerSize_90_95_chart);
/* 430 */     params.clear();
/*     */ 
/*     */ 
/*     */     
/* 434 */     params.put("memPer", Integer.valueOf(50));
/* 435 */     params.put("memPerLe", Integer.valueOf(90));
/* 436 */     int memPerSize_50_90 = this.systemInfoService.countByParams(params);
/* 437 */     double b = 0.0D;
/* 438 */     if (totalSystemInfoSize != 0) {
/* 439 */       b = memPerSize_50_90 / totalSystemInfoSize;
/*     */     }
/* 441 */     ChartInfo memPerSize_50_90_chart = new ChartInfo();
/* 442 */     memPerSize_50_90_chart.setItem("内存>=50%且<90%");
/* 443 */     memPerSize_50_90_chart.setCount(Integer.valueOf(memPerSize_50_90));
/* 444 */     memPerSize_50_90_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(b), 2)));
/* 445 */     chartInfoList1.add(memPerSize_50_90_chart);
/* 446 */     params.clear();
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 451 */     params.put("memPerLe", Integer.valueOf(50));
/* 452 */     int memPerSize_50 = this.systemInfoService.countByParams(params);
/* 453 */     double bb = 0.0D;
/* 454 */     if (totalSystemInfoSize != 0) {
/* 455 */       bb = memPerSize_50 / totalSystemInfoSize;
/*     */     }
/* 457 */     ChartInfo memPerSize_50_chart = new ChartInfo();
/* 458 */     memPerSize_50_chart.setItem("内存<50%");
/* 459 */     memPerSize_50_chart.setCount(Integer.valueOf(memPerSize_50));
/* 460 */     memPerSize_50_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(bb), 2)));
/* 461 */     chartInfoList1.add(memPerSize_50_chart);
/* 462 */     params.clear();
/*     */ 
/*     */     
/* 465 */     model.addAttribute("chartInfoList1", JSONUtil.parseArray(chartInfoList1));
/*     */ 
/*     */ 
/*     */     
/* 469 */     params.put("cpuPer", Integer.valueOf(95));
/* 470 */     int cpuPerSize_95 = this.systemInfoService.countByParams(params);
/* 471 */     double c_95 = 0.0D;
/* 472 */     if (totalSystemInfoSize != 0) {
/* 473 */       c_95 = cpuPerSize_95 / totalSystemInfoSize;
/*     */     }
/* 475 */     ChartInfo cpuPerSize_95_chart = new ChartInfo();
/* 476 */     cpuPerSize_95_chart.setItem("CPU>=95%");
/* 477 */     cpuPerSize_95_chart.setCount(Integer.valueOf(cpuPerSize_95));
/* 478 */     cpuPerSize_95_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(c_95), 2)));
/* 479 */     chartInfoList2.add(cpuPerSize_95_chart);
/* 480 */     params.clear();
/*     */ 
/*     */ 
/*     */     
/* 484 */     params.put("cpuPer", Integer.valueOf(90));
/* 485 */     params.put("cpuPerLe", Integer.valueOf(95));
/* 486 */     int cpuPerSize_90_95 = this.systemInfoService.countByParams(params);
/* 487 */     double c_90_95 = 0.0D;
/* 488 */     if (totalSystemInfoSize != 0) {
/* 489 */       c_90_95 = cpuPerSize_90_95 / totalSystemInfoSize;
/*     */     }
/* 491 */     ChartInfo cpuPerSize_90_95_chart = new ChartInfo();
/* 492 */     cpuPerSize_90_95_chart.setItem("CPU>=90%且<95%");
/* 493 */     cpuPerSize_90_95_chart.setCount(Integer.valueOf(cpuPerSize_90_95));
/* 494 */     cpuPerSize_90_95_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(c_90_95), 2)));
/* 495 */     chartInfoList2.add(cpuPerSize_90_95_chart);
/* 496 */     params.clear();
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 501 */     params.put("cpuPerLe", Integer.valueOf(90));
/* 502 */     params.put("cpuPer", Integer.valueOf(50));
/* 503 */     int perSize_50_90 = this.systemInfoService.countByParams(params);
/* 504 */     double e = 0.0D;
/* 505 */     if (totalSystemInfoSize != 0) {
/* 506 */       e = perSize_50_90 / totalSystemInfoSize;
/*     */     }
/* 508 */     ChartInfo perSize_50_90_chart = new ChartInfo();
/* 509 */     perSize_50_90_chart.setItem("CPU>=50%且<90%");
/* 510 */     perSize_50_90_chart.setCount(Integer.valueOf(perSize_50_90));
/* 511 */     perSize_50_90_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(e), 2)));
/* 512 */     chartInfoList2.add(perSize_50_90_chart);
/* 513 */     params.clear();
/*     */ 
/*     */ 
/*     */     
/* 517 */     params.put("cpuPerLe", Integer.valueOf(50));
/* 518 */     int perSize_50 = this.systemInfoService.countByParams(params);
/* 519 */     double f = 0.0D;
/* 520 */     if (totalSystemInfoSize != 0) {
/* 521 */       f = perSize_50 / totalSystemInfoSize;
/*     */     }
/* 523 */     ChartInfo perSize_50_chart = new ChartInfo();
/* 524 */     perSize_50_chart.setItem("CPU<50%");
/* 525 */     perSize_50_chart.setCount(Integer.valueOf(perSize_50));
/* 526 */     perSize_50_chart.setPercent(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(f), 2)));
/* 527 */     chartInfoList2.add(perSize_50_chart);
/* 528 */     params.clear();
/*     */ 
/*     */     
/* 531 */     model.addAttribute("chartInfoList2", JSONUtil.parseArray(chartInfoList2));
/* 532 */     params.clear();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @RequestMapping({"hostDrawList"})
/*     */   public String hostDrawList(SystemInfo systemInfo, Model model, HttpServletRequest request) {
/* 546 */     Map<String, Object> params = new HashMap<>();
/*     */     try {
/* 548 */       StringBuffer url = new StringBuffer();
/* 549 */       String hostname = null;
/* 550 */       if (!StringUtils.isEmpty(systemInfo.getHostname())) {
/* 551 */         hostname = systemInfo.getHostname();
/* 552 */         params.put("hostname", hostname.trim());
/* 553 */         url.append("&hostname=").append(hostname);
/*     */       } 
/* 555 */       if (!StringUtils.isEmpty(systemInfo.getState())) {
/* 556 */         params.put("state", systemInfo.getState());
/* 557 */         url.append("&state=").append(systemInfo.getState());
/*     */       } 
/* 559 */       if (!StringUtils.isEmpty(systemInfo.getOrderBy())) {
/* 560 */         params.put("orderBy", systemInfo.getOrderBy());
/* 561 */         params.put("orderType", systemInfo.getOrderType());
/* 562 */         url.append("&orderBy=").append(systemInfo.getOrderBy());
/* 563 */         url.append("&orderType=").append(systemInfo.getOrderType());
/*     */       } 
/*     */ 
/*     */       
/* 567 */       LicenseUtil.checkHostList(systemInfo, model);
/*     */ 
/*     */       
/* 570 */       PageInfo<SystemInfo> pageInfo = this.systemInfoService.selectByParams(params, systemInfo.getPage().intValue(), systemInfo.getPageSize().intValue());
/*     */       
/* 572 */       hostAddVal(pageInfo);
/*     */ 
/*     */       
/* 575 */       PageUtil.initPageNumber(pageInfo, model);
/* 576 */       model.addAttribute("pageUrl", "/systemInfo/systemInfoList?1=1" + url.toString());
/* 577 */       model.addAttribute("page", pageInfo);
/* 578 */       model.addAttribute("systemInfo", systemInfo);
/*     */     }
/* 580 */     catch (Exception e) {
/* 581 */       logger.error("查询主机列表错误", e);
/* 582 */       this.logInfoService.save("查询主机列表错误", e.toString(), "1");
/*     */     } 
/* 584 */     return "hostDraw/list";
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void hostAddVal(PageInfo<SystemInfo> pageInfo) throws Exception {
/* 594 */     Map<String, Object> paramsAppInfo = new HashMap<>();
/* 595 */     for (SystemInfo systemInfo1 : pageInfo.getList()) {
/* 596 */       paramsAppInfo.put("hostname", systemInfo1.getHostname());
/* 597 */       systemInfo1.setRxbyt(FormatUtil.kbToM(systemInfo1.getRxbyt()) + "/s");
/* 598 */       systemInfo1.setTxbyt(FormatUtil.kbToM(systemInfo1.getTxbyt()) + "/s");
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */       
/* 608 */       HostUtil.setSysImage(systemInfo1);
/*     */       
/* 610 */       List<DeskState> deskStates = this.deskStateService.selectAllByParams(paramsAppInfo);
/* 611 */       Double sumSize = Double.valueOf(0.0D);
/* 612 */       Double useSize = Double.valueOf(0.0D);
/* 613 */       for (DeskState deskState : deskStates) {
/* 614 */         if (!StringUtils.isEmpty(deskState.getSize()) && !StringUtils.isEmpty(deskState.getUsed())) {
/* 615 */           sumSize = Double.valueOf(sumSize.doubleValue() + Double.valueOf(deskState.getSize().replace("G", "")).doubleValue());
/* 616 */           useSize = Double.valueOf(useSize.doubleValue() + Double.valueOf(deskState.getUsed().replace("G", "")).doubleValue());
/*     */         } 
/*     */       } 
/* 619 */       systemInfo1.setDiskPer(Double.valueOf(0.0D));
/* 620 */       if (sumSize.doubleValue() != 0.0D) {
/* 621 */         systemInfo1.setDiskPer(Double.valueOf(FormatUtil.formatDouble(Double.valueOf(useSize.doubleValue() / sumSize.doubleValue() * 100.0D), 2)));
/*     */       }
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @RequestMapping({"hostDraw"})
/*     */   public String hostDraw(Model model, HttpServletRequest request) {
/* 637 */     String id = request.getParameter("id");
/* 638 */     if (StringUtils.isEmpty(id)) {
/* 639 */       return "error/500";
/*     */     }
/*     */     
/*     */     try {
/* 643 */       SystemInfo systemInfo = this.systemInfoService.selectById(id);
/* 644 */       String hostname = systemInfo.getHostname();
/* 645 */       Map<String, Object> params = new HashMap<>();
/* 646 */       params.put("hostname", hostname);
/* 647 */       model.addAttribute("systemInfo", systemInfo);
/* 648 */       int totalAppSize = this.appInfoService.countByParams(params);
/* 649 */       model.addAttribute("totalAppSize", Integer.valueOf(totalAppSize));
/* 650 */       int totalDockerSize = this.dockerInfoService.countByParams(params);
/* 651 */       model.addAttribute("totalDockerSize", Integer.valueOf(totalDockerSize));
/*     */       
/* 653 */       params.put("state", "2");
/* 654 */       int downAppSize = this.appInfoService.countByParams(params);
/* 655 */       model.addAttribute("downAppSize", Integer.valueOf(downAppSize));
/* 656 */       int downDockerSize = this.dockerInfoService.countByParams(params);
/* 657 */       model.addAttribute("downDockerSize", Integer.valueOf(downDockerSize));
/*     */ 
/*     */       
/* 660 */       Double maxCpuState = this.cpuStateService.selectMaxByHostname(hostname);
/* 661 */       model.addAttribute("maxCpuState", maxCpuState);
/* 662 */       Double maxMemState = this.memStateService.selectMaxByHostname(hostname);
/* 663 */       model.addAttribute("maxMemState", maxMemState);
/*     */       
/* 665 */       model.addAttribute("historyDataOut", this.commonConfig.getHistoryDataOut());
/*     */       
/* 667 */       params.clear();
/* 668 */       params.put("hostname", hostname);
/* 669 */       PageInfo pageInfoLoad = this.sysLoadStateService.selectByParams(params, 1, 1);
/* 670 */       if (!CollectionUtil.isEmpty(pageInfoLoad.getList())) {
/* 671 */         model.addAttribute("sysLoadState", pageInfoLoad.getList().get(0));
/*     */       } else {
/* 673 */         model.addAttribute("sysLoadState", new SysLoadState());
/*     */       } 
/* 675 */       model.addAttribute("maxOneLoad", this.sysLoadStateService.selectMaxOneByHostname(hostname));
/* 676 */       model.addAttribute("maxFiveLoad", this.sysLoadStateService.selectMaxFiveByHostname(hostname));
/* 677 */       model.addAttribute("maxFifteenLoad", this.sysLoadStateService.selectMaxFifteenByHostname(hostname));
/*     */ 
/*     */       
/* 680 */       PageInfo pageInfoNetIo = this.netIoStateService.selectByParams(params, 1, 1);
/* 681 */       if (!CollectionUtil.isEmpty(pageInfoNetIo.getList())) {
/* 682 */         model.addAttribute("netIoState", pageInfoNetIo.getList().get(0));
/*     */       } else {
/* 684 */         model.addAttribute("netIoState", new NetIoState());
/*     */       } 
/*     */       
/* 687 */       model.addAttribute("maxRxbyt", this.netIoStateService.selectMaxRxbytByHostname(hostname));
/* 688 */       model.addAttribute("maxTxbyt", this.netIoStateService.selectMaxTxbytByHostname(hostname));
/* 689 */       model.addAttribute("maxRxpck", this.netIoStateService.selectMaxRxpckByHostname(hostname));
/* 690 */       model.addAttribute("maxTxpck", this.netIoStateService.selectMaxTxpckByHostname(hostname));
/*     */       
/* 692 */       params.clear();
/* 693 */       params.put("hostname", "主机下线告警：" + hostname);
/* 694 */       int hostDownSize = this.logInfoService.countByParams(params);
/* 695 */       model.addAttribute("hostDownSize", Integer.valueOf(hostDownSize));
/*     */       
/* 697 */       params.clear();
/* 698 */       params.put("hostname", hostname);
/* 699 */       List<AppInfo> appInfoList = this.appInfoService.selectAllByParams(params);
/* 700 */       for (AppInfo appInfo1 : appInfoList) {
/* 701 */         appInfo1.setWritesBytes(FormatUtil.mToG(appInfo1.getWritesBytes()));
/* 702 */         appInfo1.setReadBytes(FormatUtil.mToG(appInfo1.getReadBytes()));
/*     */       } 
/* 704 */       model.addAttribute("appInfoList", appInfoList);
/*     */       
/* 706 */       List<PortInfo> portInfoList = this.portInfoService.selectAllByParams(params);
/* 707 */       model.addAttribute("portInfoList", portInfoList);
/*     */       
/* 709 */       List<FileWarnInfo> fileWarnInfoList = this.fileWarnInfoService.selectAllByParams(params);
/* 710 */       for (FileWarnInfo info : fileWarnInfoList) {
/* 711 */         params.put("fileWarnId", info.getId());
/* 712 */         Integer count = this.fileWarnStateService.countByParams(params);
/* 713 */         info.setWarnDatas(count + "");
/*     */       } 
/* 715 */       model.addAttribute("fileWarnInfoList", fileWarnInfoList);
/*     */       
/* 717 */       List<DockerInfo> dockerInfoList = this.dockerInfoService.selectAllByParams(params);
/* 718 */       model.addAttribute("dockerInfoList", dockerInfoList);
/*     */ 
/*     */       
/* 721 */       List<DeskState> deskStateList = this.deskStateService.selectAllByParams(params);
/* 722 */       model.addAttribute("deskStateList", deskStateList);
/*     */       
/* 724 */       List<DeskIo> deskIoList = this.deskIoService.selectAllByParams(params);
/* 725 */       model.addAttribute("deskIoList", deskIoList);
/*     */       
/* 727 */       List<DiskSmart> diskSmartList = this.diskSmartService.selectAllByParams(params);
/* 728 */       model.addAttribute("diskSmartList", diskSmartList);
/*     */ 
/*     */       
/* 731 */       List<CpuTemperatures> cpuTemperaturesList = this.cpuTemperaturesService.selectAllByParams(params);
/* 732 */       model.addAttribute("cpuTemperaturesList", cpuTemperaturesList);
/*     */     
/*     */     }
/* 735 */     catch (Exception e) {
/* 736 */       logger.error("主机画像错误", e);
/* 737 */       this.logInfoService.save("主机画像错误", e.toString(), "1");
/*     */     } 
/* 739 */     return "hostDraw/view";
/*     */   }
/*     */ }


/* Location:              /Users/zhangyongxin/soft-install/wgcloud/wgcloud-v3.3.5/server/bank/wgcloud-server-release.jar!/BOOT-INF/classes/com/wgcloud/controller/DashboardCotroller.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */